package cn.stylefeng.guns.modular.business.frequency.financedetail.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.financedetail.service.FinanceDetailService;
import cn.stylefeng.guns.modular.business.frequency.financedetail.model.param.FinanceDetailParam;

import javax.annotation.Resource;

/**
 * 财务明细表 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:17
 */
@RestController
public class FinanceDetailController {

    @Resource
    private FinanceDetailService financeDetailService;

    /**
     * 分页查询财务明细表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/financeDetail/page")
    @BusinessLog(title = "财务明细表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(FinanceDetailParam financeDetailParam) {
        return new SuccessResponseData(financeDetailService.page(financeDetailParam));
    }

    /**
     * 获取全部财务明细表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/financeDetail/list")
    @BusinessLog(title = "财务明细表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(FinanceDetailParam financeDetailParam) {
        return new SuccessResponseData(financeDetailService.list(financeDetailParam));
    }

    /**
     * 查看详情财务明细表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/financeDetail/detail")
    @BusinessLog(title = "财务明细表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(FinanceDetailParam.detail.class) FinanceDetailParam financeDetailParam) {
        return new SuccessResponseData(financeDetailService.detail(financeDetailParam));
    }

    /**
     * 添加财务明细表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/financeDetail/add")
    @BusinessLog(title = "财务明细表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(FinanceDetailParam.add.class) FinanceDetailParam financeDetailParam) {
        financeDetailService.add(financeDetailParam);
        return new SuccessResponseData();
    }

    /**
     * 删除财务明细表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/financeDetail/delete")
    @BusinessLog(title = "财务明细表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(FinanceDetailParam.delete.class) FinanceDetailParam financeDetailParam) {
        financeDetailService.delete(financeDetailParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑财务明细表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/financeDetail/edit")
    @BusinessLog(title = "财务明细表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(FinanceDetailParam.edit.class) FinanceDetailParam financeDetailParam) {
        financeDetailService.edit(financeDetailParam);
        return new SuccessResponseData();
    }

    /**
     * 修改状态
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/financeDetail/changeStatus")
    @BusinessLog(title = "财务明细表_修改状态", opType = LogAnnotionOpTypeEnum.CHANGE_STATUS)
    public ResponseData changeStatus(@RequestBody @Validated(FinanceDetailParam.changeStatus.class) FinanceDetailParam financeDetailParam) {
        financeDetailService.changeStatus(financeDetailParam);
        return new SuccessResponseData();
    }

}
